<?php
	session_start();
	require_once("../db_connect.php");

	//管理者登録処理

	$Family_Name  = htmlspecialchars($_POST['Family_Name'],ENT_QUOTES,"UTF-8");
	$Given_Name   = htmlspecialchars($_POST['Given_Name'],ENT_QUOTES,"UTF-8");
	$Family_Kana  = htmlspecialchars($_POST['Family_Kana'],ENT_QUOTES,"UTF-8");
	$Given_Kana   = htmlspecialchars($_POST['Given_Kana'],ENT_QUOTES,"UTF-8");

	$Login_ID     = htmlspecialchars($_POST['Login_ID'],ENT_QUOTES,"UTF-8");
	$Password     = htmlspecialchars($_POST['Password'],ENT_QUOTES,"UTF-8");
	$K_Password   = htmlspecialchars($_POST['K_Password'],ENT_QUOTES,"UTF-8");

	$sql = "INSERT INTO manager(login_id,family_name,given_name,family_kana,given_kana,password) VALUES(?,?,?,?,?,?)";

	$stmt = $db->prepare($sql);

    $data = array($Login_ID,
                  $Family_Name,
                  $Given_Name,
                  $Family_Kana,
                  $Given_Kana,
                  $Password
    );

	$db->execute($stmt, $data);     //UPDATE文を実行

	if (PEAR::isError($db)) {       //SQLの実行に失敗すればここでエラー文を出力
    	die($res->getMessage());
	}

	$_SESSION["manager_name"] = $Family_Name.$Given_Name;
	$_SESSION["login_id"] = $login_id;

	header("Location: Manager.php");
   ?>